package com.note.simpleadmin.utils;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

/***
 *@ClaseName:PasswordUtils
 *
 *@Decription:
 *
 *@Author: xubingbing
 *
 *@Date:2019/1/28 0028 21:04
 */
public class PasswordUtils {
    public static String encode(String credentials, String salt) {
        String hashAlgorithmName = "MD5";
        int hashIterations = 1024;
        ByteSource credentialsSalt = ByteSource.Util.bytes(salt);
        Object obj = new SimpleHash(hashAlgorithmName, credentials, credentialsSalt, hashIterations);
        return obj.toString();
    }

}
